package com.hyy.backend.service.impl;

import com.hyy.backend.dao.CommentMapper;
import com.hyy.backend.dto.CommentDTO;
import com.hyy.backend.entity.Comment;
import com.hyy.backend.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;


    @Override
    public boolean addComment(Comment comment) {
        try {
            commentMapper.insertComment(comment);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public boolean deleteComment(Integer commentId) {
        try {
            commentMapper.deleteComment(commentId);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    @Override
    public List<Comment> getCommentsByPostId(Integer postId) {
        return commentMapper.selectByPostId(postId);
    }

}
